local joyex__beige = fk.CreateSkill {

  name = "joyex__beige",

  tags = {  },

}



joyex__beige:addEffect(fk.Damaged, {
  name = "joyex__beige",
  anim_type = "masochism",
  events = {fk.Damaged},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(joyex__beige.name) and data.card and data.card.trueName == "slash" and not data.to.dead and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForDiscard(player, 1, 1, true, joyex__beige.name, true, ".", "#joyex__beige-discard::"..target.id, true)
    if #card > 0 then
      event:setCostData(self, card)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    if player.dead then return false end
    local dis_card = Fk:getCardById(event:getCostData(self)[1])
    room:throwCard(event:getCostData(self), joyex__beige.name, player, player)
    if dis_card.color == Card.Red then
      if not target.dead and target:isWounded() then
        room:recover{
          who = target,
          num = 1,
          recoverBy = player,
          skillName = joyex__beige.name
        }
      end
      if not target.dead then
        target:drawCards(2, joyex__beige.name)
      end
    elseif dis_card.suit == Card.Club then
      if data.from and not data.from.dead then
        room:askForDiscard(data.from, 2, 2, true, joyex__beige.name, false)
      end
    elseif dis_card.suit == Card.Spade then
      if data.from and not data.from.dead then
        data.from:turnOver()
      end
    end
  end,
})

return joyex__beige